home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
WINPROGS
/
UPC12BS1.ZIP
/
UUCICO
/
ULIBNT.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-03
|
29KB
|
840 lines
/*--------------------------------------------------------------------*/
/* u l i b n t . c */
/* */
/* Windows NT serial port support for UUCICO */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) David M. Watt 1993, All Rights Reserved */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Changes Copyright (c) 1989-1993 by Kendra Electronic */
/* Wonderworks. */
/* */
/* All rights reserved except those explicitly granted by the */
/* UUPC/extended license agreement. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* RCS Information */
/*--------------------------------------------------------------------*/
/*
* $Id: ulibnt.c 1.6 1993/10/03 22:09:09 ahd Exp $
* $Log: ulibnt.c $
* Revision 1.6 1993/10/03 22:09:09 ahd
* Use unsigned long to display speed
*
* Revision 1.5 1993/09/26 03:32:27 dmwatt
* Use Standard Windows NT error message module
*
* Revision 1.4 1993/09/25 03:07:56 ahd
* Add standard Windows NT error message calls
*
* Revision 1.3 1993/09/21 01:42:13 ahd
* Use standard MAXPACK limit for save buffer size
*
* Revision 1.2 1993/09/20 04:50:57 ahd
* Break out of ULIBOS2.C
*
* Revision 1.14 1993/05/30 15:25:50 ahd
* Multiple driver support
*
* Revision 1.13 1993/05/30 00:08:03 ahd
* Multiple communications driver support
* Delete trace functions
*
* Revision 1.12 1993/05/09 03:41:47 ahd
* Make swrite accept constant input strings
*
* Revision 1.11 1993/04/11 00:34:11 ahd
* Global edits for year, TEXT, etc.
*
* Revision 1.10 1993/04/10 21:25:16 dmwatt
* Add Windows NT support
*
* Revision 1.9 1993/04/05 04:32:19 ahd
* Additional traps for modem dropping out
*
* Revision 1.8 1993/04/04 04:57:01 ahd
* Add configurable OS/2 priority values
*
* Revision 1.7 1992/12/30 13:02:55 dmwatt
* Dual path for Windows NT and OS/2
*
* Revision 1.6 1992/12/11 12:45:11 ahd
* Correct RTS handshake
*
* Revision 1.5 1992/12/04 01:00:27 ahd
* Add copyright message, reblock other comments
*
* Revision 1.4 1992/11/29 22:09:10 ahd
* Add new define for BC++ OS/2 build
*
* Revision 1.3 1992/11/19 03:00:39 ahd
* drop rcsid
*
* Revision 1.2 1992/11/15 20:11:48 ahd
* Add English display of modem status and error bits
*
*/
/*--------------------------------------------------------------------*/
/* System include files */
/*--------------------------------------------------------------------*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <io.h>
#include <time.h>
/*--------------------------------------------------------------------*/
/* Windows NT include files */
/*--------------------------------------------------------------------*/
#include <windows.h>
#include <limits.h>
/*--------------------------------------------------------------------*/
/* UUPC/extended include files */
/*--------------------------------------------------------------------*/
#include "lib.h"
#include "ulib.h"
#include "ssleep.h"
#include "catcher.h"
#include "commlib.h"
#include "pnterr.h"
/*--------------------------------------------------------------------*/
/* Global variables */
/*--------------------------------------------------------------------*/
currentfile();
static boolean carrierdetect = FALSE; /* Modem is not connected */
static boolean hangupNeeded = FALSE;
static boolean console = FALSE;
static currentSpeed = 0;
#define FAR_NULL ((PVOID) 0L)
/*--------------------------------------------------------------------*/
/* Definitions of control structures for DOS API */
/*--------------------------------------------------------------------*/
static HANDLE hCom;
static COMMTIMEOUTS CommTimeout;
static DCB dcb;
static BYTE com_status;
static USHORT com_error;
static USHORT usPrevPriority;
static void ShowError( const USHORT status );
static void ShowModem( const DWORD status );
/*--------------------------------------------------------------------*/
/* n o p e n l i n e */
/* */
/* Open the serial port for I/O */
/*--------------------------------------------------------------------*/
int nopenline(char *name, BPS baud, const boolean direct )
{
DWORD dwError;
BOOL rc;
if (portActive) /* Was the port already active? ahd */
closeline(); /* Yes --> Shutdown it before open ahd */
#ifdef UDEBUG
printmsg(15, "nopenline: %s, %lu",
name,
(unsigned long) baud);
#endif
/*--------------------------------------------------------------------*/
/* Validate the port format */
/*--------------------------------------------------------------------*/
if (!equal(name,"CON") && !equaln(name, "COM", 3 ))
{
printmsg(0,"nopenline: Communications port begin with COM, was %s",
name);
panic();
}
/*--------------------------------------------------------------------*/
/* Perform the open */
/*--------------------------------------------------------------------*/
hCom = CreateFile( name,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL);
/*--------------------------------------------------------------------*/
/* Check the open worked. We translation the common obvious */
/* error of file in use to english, for all other errors are we */
/* report the raw error code. */
/*--------------------------------------------------------------------*/
if (hCom == INVALID_HANDLE_VALUE) {
dwError = GetLastError();
printmsg(0, "nopenline: OpenFile error on port %s", name);
printNTerror("nopenline", dwError);
return TRUE;
}
/*--------------------------------------------------------------------*/
/* Check for special test mode */
/*--------------------------------------------------------------------*/
if ( equal(name,"CON"))
{
portActive = TRUE; /* record status for error handler */
carrierdetect = FALSE; /* Modem is not connected */
console = TRUE;
return 0;
}
console = FALSE;
/*--------------------------------------------------------------------*/
/* Reset any errors on the communications port */
/*--------------------------------------------------------------------*/
rc = ClearCommError (hCom,
&dwError,
NULL);
if (!rc) {
printmsg(0, "nopenline: Error in ClearCommError() call\n");
printNTerror("nopenline", dwError);
}
/*--------------------------------------------------------------------*/
/* Set baud rate */
/*--------------------------------------------------------------------*/